package com.ruoyi.web.controller.employ;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.employ.DictTags;
import com.ruoyi.system.service.employ.IDictTagsService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 标签对照表Controller
 * 
 * @author ruoyi
 * @date 2024-10-12
 */
@RestController
@RequestMapping("/dictTag/dictTag")
public class DictTagsController extends BaseController
{
    @Autowired
    private IDictTagsService dictTagsService;

    /**
     * 查询标签对照表列表
     */
    @PreAuthorize("@ss.hasPermi('dictTag:dictTag:list')")
    @GetMapping("/list")
    public TableDataInfo list(DictTags dictTags)
    {
        startPage();
        List<DictTags> list = dictTagsService.selectDictTagsList(dictTags);
        return getDataTable(list);
    }

    /**
     * 导出标签对照表列表
     */
    @PreAuthorize("@ss.hasPermi('dictTag:dictTag:export')")
    @Log(title = "标签对照表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DictTags dictTags)
    {
        List<DictTags> list = dictTagsService.selectDictTagsList(dictTags);
        ExcelUtil<DictTags> util = new ExcelUtil<DictTags>(DictTags.class);
        util.exportExcel(response, list, "标签对照表数据");
    }

    /**
     * 获取标签对照表详细信息
     */
    @PreAuthorize("@ss.hasPermi('dictTag:dictTag:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(dictTagsService.selectDictTagsById(id));
    }

    /**
     * 新增标签对照表
     */
    @PreAuthorize("@ss.hasPermi('dictTag:dictTag:add')")
    @Log(title = "标签对照表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DictTags dictTags)
    {
        return toAjax(dictTagsService.insertDictTags(dictTags));
    }

    /**
     * 修改标签对照表
     */
    @PreAuthorize("@ss.hasPermi('dictTag:dictTag:edit')")
    @Log(title = "标签对照表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DictTags dictTags)
    {
        return toAjax(dictTagsService.updateDictTags(dictTags));
    }

    /**
     * 删除标签对照表
     */
    @PreAuthorize("@ss.hasPermi('dictTag:dictTag:remove')")
    @Log(title = "标签对照表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dictTagsService.deleteDictTagsByIds(ids));
    }
}
